package com.kaifamiao.niofile;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;

/**
 * 1、copy(Path source, Path target, CopyOption... options)
 * 2、copy(InputStream in, Path target, CopyOption... options)
 * 3、copy(Path source, OutputStream out, CopyOption... options)
 * 4、move(Path source, OutputStream out, CopyOption... options)
 */
public class CopyFileTest {

    public static void main(String[] args) throws IOException {

        Path src = Path.of( "files-and-streams/src/com/kaifamiao/niofile/CopyFileTest.java" );

        Path dest = Path.of( "afang", src.getFileName().toString() );

        Files.copy(src, dest, StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING);

        // Files.move(src, dest, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);

    }

}
